package com.atguigu.yygh.hosp.controller;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.service.HospitalService;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

//http://127.0.0.1:8202/swagger-ui.html
@Api(tags = "医院管理")
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;

    //带条件的分页查询
    @ApiOperation("条件分页查询，带字典医院名称")
    @GetMapping("list/{pageNum}/{limit}")
    public Result listHosp(@PathVariable Integer pageNum, @PathVariable Integer limit,
                           HospitalQueryVo hospitalQueryVo){
        Page<Hospital> page = hospitalService.getHospList(pageNum,limit,hospitalQueryVo);
        return Result.ok(page);
    }

    //更新医院上线状态
    @ApiOperation("更新医院上线状态")
    @GetMapping("updateHospStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable String id, @PathVariable Integer status){
        hospitalService.updateHospStatus(id,status);
        return Result.ok();
    }

    //医院详情信息
    @ApiOperation("医院详情信息")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id){
        Map<String,Object> hospitalMap = hospitalService.showHospDetail(id);
        return Result.ok(hospitalMap);
    }



}
